#!/bin/bash
clear
if [[ "$EUID" -ne 0 ]]; then
    echo -e "\033[1;31mScript need to be run as root!\033[0m"; exit 1
fi

wget -q https://github.com/lfasmpao/open-http-puncher/releases/download/0.1/ohpserver-linux32.zip
unzip ohpserver-linux32.zip
chmod +x ohpserver
mv ohpserver /usr/bin/

echo "[Unit]
Description=Dropbear OHP
Wants=network.target
After=network.target

[Service]
ExecStart=/usr/bin/ohpserver -port 355 -proxy 127.0.0.1:8888 -tunnel 127.0.0.1:440
Restart=always
RestartSec=3

[Install]
WantedBy=multi-user.target" > /etc/systemd/system/ohp-dropbear.service
systemctl daemon-reload
systemctl enable ohp-dropbear
systemctl start ohp-dropbear

echo "[Unit]
Description=OpenVPN OHP
Wants=network.target
After=network.target

[Service]
ExecStart=/usr/bin/ohpserver -port 356 -proxy 127.0.0.1:8888 -tunnel 127.0.0.1:1194
Restart=always
RestartSec=3

[Install]
WantedBy=multi-user.target" > /etc/systemd/system/ohp-openvpn.service

systemctl daemon-reload
systemctl enable ohp-openvpn
systemctl start ohp-openvpn

echo
echo -e "\033[1;32mCongratulation, We are done with the ohpserver installation.\033[0m"
echo
echo 'Use my referral link https://m.do.co/c/a28a40414d6a'
echo 'to gets $100 credit into your DigitalOcean account.'
echo 'Created by Doctype, Powered by Cybertize'
echo 'Copyright 2021, Allright reserved.'
echo; sleep 5
